package com.kt.emall.product.web;

import com.kt.emall.product.service.SkuInfoService;
import com.kt.emall.product.vo.SkuItemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

/**
 * @program: e-mall
 * @description: 商品详情
 * @author: KamTang
 * @create: 2021-11-22 08:40
 **/
@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;

    /**
     * 展示当前sku的详情
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {
        System.out.println("准备查询" + skuId + "详情");
        SkuItemVO vo = skuInfoService.getItemInfo(skuId);
        model.addAttribute("item", vo);
        return "item";
    }
}
